<template>
  <div class="index">
    <div class="left">
      <h2>酒店管理系统</h2>
      <el-menu
        router
        active-text-color="#ffd04b"
        background-color="#142334"
        default-active="2"
        text-color="#fff"
      >
        <el-sub-menu index="1">
          <template #title>
            <el-icon><User /></el-icon>
            <span>账号管理</span>
          </template>
          <el-menu-item index="/index/role">角色管理</el-menu-item>
          <el-menu-item index="/index/user">用户管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="2">
          <template #title>
            <el-icon><House /></el-icon>
            <span>客房管理</span>
          </template>
          <el-menu-item index="/index/roomtype">房型管理</el-menu-item>
          <el-menu-item index="/index/room">房间管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="3">
          <template #title>
            <el-icon><Avatar /></el-icon>
            <span>客户管理</span>
          </template>
          <el-menu-item index="/index/livein">入住管理</el-menu-item>
          <el-menu-item index="/index/order">订单管理</el-menu-item>
        </el-sub-menu>
        <el-sub-menu index="4">
          <template #title>
            <el-icon><Setting /></el-icon>
            <span>系统管理</span>
          </template>
          <el-menu-item index="/index/menu">菜单管理</el-menu-item>
          <el-menu-item index="/index/dict">字典管理</el-menu-item>
        </el-sub-menu>
      </el-menu>
    </div>
    <div class="right">
      <div class="top">
        <el-menu
          router
          mode="horizontal"
          background-color="#142334"
          text-color="#fff"
          active-text-color="#ffd04b"
          :ellipsis="false"
        >
          <el-menu-item index="/index/home">
            <el-icon><HomeFilled /></el-icon>首页
          </el-menu-item>
          <el-menu-item index="/index/mail">
            <el-icon><Message /></el-icon>Mail
          </el-menu-item>
          <el-menu-item index="/index/message">
            <el-icon><Notification /></el-icon>Message
          </el-menu-item>
          <el-sub-menu index="4">
            <template #title>{{ user.username }}</template>
            <el-menu-item index="/index/mine">个人中心</el-menu-item>
            <el-menu-item index="/index/setpwd">修改密码</el-menu-item>
            <el-menu-item index="" @click="exit">退出登录</el-menu-item>
          </el-sub-menu>
        </el-menu>
      </div>
      <div class="content">
        <RouterView />
      </div>
    </div>
  </div>
</template>
<script setup lang="ts">
import {
  Avatar,
  Setting,
  User,
  HomeFilled,
  House,
  Message,
  Notification,
} from '@element-plus/icons-vue'

import { ElMessageBox } from 'element-plus'

import { useUserStore } from '@/store/user'
const userStore = useUserStore()
const user = userStore.currentUser()

function exit() {
  ElMessageBox.confirm('确定退出登录吗？', '提示', {
    confirmButtonText: '确定',
    cancelButtonText: '取消',
    type: 'warning',
  }).then(() => {
    userStore.logout()
  })
}
</script>
<style scoped lang="scss">
.index {
  width: 100vw;
  height: 100vh;
  display: flex;
  .left {
    width: 200px;
    background-color: #142334;
    color: white;
    h2 {
      font-size: 30px;
      font-family: hotel;
      text-align: center;
      height: 60px;
      line-height: 60px;
    }
  }
  .right {
    flex: 1;
    display: flex;
    flex-direction: column;
    .top {
      height: 60px;
      background-color: #142334;
      color: white;
      display: flex;
      justify-content: flex-end;
    }
    .content {
      flex: 1;
      padding: 5px;
    }
  }
}
</style>
